package net.javamine.util.entityUtils.utils;

import java.io.IOException;
import java.io.Writer;
import java.util.Map;

import freemarker.template.TemplateTransformModel;

/**
 * Freemarker:首字母小写
 * @author <a href="mailto: java_lht@163.com">Lht</a>
 * @since 2012-11-29
 * @version 1.0
 */
public class LowerCaseFirstCharacter implements TemplateTransformModel {
	
	@SuppressWarnings("rawtypes")
	public Writer getWriter(Writer out, Map map){
        return new UpperFirstCharacter(out);
    }
	
    private class UpperFirstCharacter extends Writer {
    	
        private Writer out;
        
        UpperFirstCharacter(Writer out){
            this.out = out;
        }
        
        public void write(char[] cbuf, int off, int len) throws IOException{
            out.write(new String(cbuf, off, len).substring(0, 1).toLowerCase() + new String(cbuf, off, len).substring(1, new String(cbuf, off, len).length()));
        }
        
        public void flush() throws IOException {
            out.flush();
        }
        
        public void close() throws IOException{
			out.close();
        }
        
    }


}
